package com.atguigu.gulimall.ware.dao;

import com.atguigu.gulimall.ware.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 商品库存
 * 
 * @author YuGuoJian
 * @email yu925074596@163.com
 * @date 2021-11-22 23:35:38
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {

    @Update("update wms_ware_sku set stock=stock+#{skuNum} where sku_id = #{skuId} and ware_id = #{wareId}")
    void addStock(@Param("skuId") Long skuId,@Param("wareId")  Long wareId,@Param("skuNum")  Integer skuNum);

    List<Long> listWareIdHasStock(@Param("skuId") Long skuId);

    Long lockSkuStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("num") Integer num);

    void unlockStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("num") Integer num);
}
